package com.gdiot.smart_scale;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class SellList_Adapter extends RecyclerView.Adapter<SellList_Adapter.ViewHolder> {

    Context context;
    List<sell_list> lists;

    public SellList_Adapter(List<sell_list> sell_lists) {
        this.lists = sell_lists;
    }

    public class ViewHolder extends RecyclerView.ViewHolder{

        TextView ITEM_SELL_NAME,ITEM_SELL_PRICE,ITEM_SELL_WEIGHT,ITEM_SELL_ALLPRICE;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);

            ITEM_SELL_NAME = itemView.findViewById(R.id.item_list_name);
            ITEM_SELL_PRICE= itemView.findViewById(R.id.item_list_price);
            ITEM_SELL_WEIGHT= itemView.findViewById(R.id.item_list_weight);
            ITEM_SELL_ALLPRICE= itemView.findViewById(R.id.item_list_allprice);
        }
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_sell_list,parent,false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull SellList_Adapter.ViewHolder holder, int position) {
        sell_list mysell_list = lists.get(position);
        holder.ITEM_SELL_NAME.setText(mysell_list.getName());
        holder.ITEM_SELL_PRICE.setText(mysell_list.getPrice());
        holder.ITEM_SELL_WEIGHT.setText(mysell_list.getWeight());
        holder.ITEM_SELL_ALLPRICE.setText(mysell_list.getAll());

    }


    @Override
    public int getItemCount() {
        return lists.size();
    }

}
